PyTorch Recipes by Pradeepta Mishra

PyTorch Recipes by Pradeepta Mishra

Author:Pradeepta Mishra
Language: eng
Format: epub
ISBN: 9781484242582
Publisher: Apress


Solution

By using the built-in function available in the neural network module, we can implement an RNN model.

How It Works

Let’s look at the following example. The neural network module in the PyTorch library contains the RNN function. In the following script, we use the input matrix size, the number of neurons in the hidden layer, and the number of hidden layers in the network.

After creating the RNN class function, we need to provide the optimization function, which is Adam, and this time, the loss function is the mean square loss function. Since the objective is to make predictions of a continuous variable, we use MSELoss function in the optimization layer.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.